package cm.day11;

import org.dom4j.Document;
import org.dom4j.DocumentException;
import org.dom4j.Element;
import org.dom4j.io.SAXReader;

import java.util.List;

public class Test4 {
    public static void main(String[] args) throws DocumentException {
       Document document=new SAXReader().read("src/books.xml");
       Element rootElement= document.getRootElement();
        List<Element>allBookElement=rootElement.elements();
        for (Element element : allBookElement) {
            String bookName=element.elementText("书名");
            System.out.println(bookName);
            String press=element.elementText("出版社");
            System.out.println(press);
            String time=element.elementText("出版日期");
            System.out.println(time);
            String price=element.elementText("价格");
            String id=element.elementText("id");
            System.out.println(id);
        }

    }
}
